//
//  NoDataCellDM.m
//  WGFGlobalHouses
//
//  Created by welldone on 15/5/8.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "NoDataCellDM.h"



@interface NoDataCellDM ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong)UITableView *listView;
@property (nonatomic,strong)UIViewController *vC;
@property (nonatomic,strong) NodataCell *cell;

@end

@implementation NoDataCellDM
@synthesize listView,vC,cell,refreshBtn;


-(instancetype)initWithTableView:(UITableView*)tableView withVc:(UIViewController*)vc{

    self = [super init];
    if (self) {
        listView = tableView;
        vC = vc;
    }
    return self;
}


-(void)setState:(nodataCellState)state{

    if (state==nodataCellStateNorMal) {
        
        [self.listView  setDataSource:vC];
        [self.listView setDelegate:vC];
        [self.listView reloadData];
    }else{
    
        [self.listView  setDataSource:self];
        [self.listView setDelegate:self];
        [cell setState:state];
        
        [self.listView reloadData];
    }
}



#pragma tableView delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    [self.listView setContentOffset:CGPointMake(0, 0)];
    [self.listView setScrollEnabled:NO];
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(!cell){
        cell = [[NodataCell alloc] initWithFrame:self.listView.frame];
        [cell setState:nodataCellStateLoading];
        self.refreshBtn = cell.refreshBtn;
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPat{
   
    return 20;
}

@end
